home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 5
/
Aminet 5 - March 1995.iso
/
Aminet
/
mus
/
edit
/
AlgoRhythms.lha
/
AlgoRhythms
/
Source
/
menus.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-25
|
5KB
|
193 lines
/* Menus.c
Copyright (c) 1990,1991,1992,1993 by Thomas E. Janzen
All Rights Reserved
THIS SOFTWARE IS FURNISHED FREE OF CHARGE FOR STUDY AND USE AND MAY
BE COPIED ONLY FOR PERSONAL USE OR COMPLETELY AS OFFERED WITH NO
CHANGES FOR FREE DISTRIBUTION. NO TITLE TO AND OWNERSHIP OF THE
SOFTWARE IS HEREBY TRANSFERRED. THOMAS E. JANZEN ASSUMES NO
RESPONSIBILITY FOR THE USE OR RELIABILITY OF THIS SOFTWARE.
Thomas E. Janzen
208A Olde Derby Road
Norwood, MA 02062-1761
(617)769-7733
*/
/*
** FACILITY:
**
** AlgoRhythms music improviser on Commodore (TM) Amiga (TM)
** compiled with SAS/C Amiga Compiler 6.50
**
** ABSTRACT:
**
** Menus.c manages menu set-up and interaction.
**
** AUTHORS: Thomas E. Janzen
**
** CREATION DATE: 26-MAR-1990
**
** MODIFICATION HISTORY:
** DATE NAME DESCRIPTION
** 19 OCT 91 T. Janzen add menu name niceties.
** 4 Jan 92 TEJ last changes for 2.0
** 2 Feb 92 TEJ use scale_list.h
** 13 oct 93 TEJ Use gadtools menus.
**--
*/
#include <stdio.h>
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <clib/intuition_protos.h>
#include <proto/intuition.h>
#include <graphics/text.h>
#include <proto/dos.h>
#include <proto/graphics.h>
#include <proto/exec.h>
#include <proto/gadtools.h>
#include <clib/gadtools_protos.h>
#include <libraries/gadtools.h>
#include "Window.h"
#include "AlgoRhythms.h"
#include "scale_list.h"
#include "Menus.h"
static struct MenuItem *record_item; /* need to clear check on record */
static struct Menu *menuStrip;
static struct NewMenu newmenus[] =
{
/* type, label, commkey, flags, mutualexc, userdata */
{ NM_TITLE, "Project", 0, 0, 0, 0},
{ NM_ITEM, "Play", "P", 0, 0, 0},
{ NM_ITEM, "Stop", "S", 0, 0, 0},
{ NM_ITEM, "Continue", "C", 0, 0, 0},
{ NM_ITEM, "Load Form...", "L", 0, 0, 0},
{ NM_ITEM, "Save Form...", "F", 0, 0, 0},
{ NM_ITEM, "Record", "R",CHECKIT | MENUTOGGLE, 0, 0},
{ NM_ITEM, "Erase", "E", 0, 0, 0},
{ NM_ITEM, "Save MIDI...", "M", 0, 0, 0},
{ NM_ITEM, "About", "A", 0, 0, 0},
{ NM_ITEM, "Quit", "Q", 0, 0, 0},
{ NM_TITLE, "Music", 0, 0, 0, 0},
{ NM_ITEM, "Redraw", "D", 0, 0, 0},
#if 0
{ NM_ITEM, "Form", "B", 0, 0, 0},
{ NM_ITEM, "Voice", "V", 0, 0, 0},
{ NM_ITEM, "Orchestra", "O", 0, 0, 0},
{ NM_ITEM, "Colors", "G", 0, 0, 0},
#endif
{NM_END,0,0,0,0,0}
};
void init_menu(void)
/*
** FUNCTIONAL DESCRIPTION:
** fills out voice menu and installs all menus
**
** DESIGN:
** ROUTINE
** : FOR voice = 0 to <MAXVOICE
** : : Fill out a voice menu item
** : ENDFOR
** : SetMenuStrip
** : OnMenu()
** ENDROUTINE
*/
{
menuStrip = CreateMenus(newmenus, TAG_END);
LayoutMenus(menuStrip, vi, TAG_END);
SetMenuStrip(w, menuStrip);
/*
** find the record menu item
*/
record_item = menuStrip->FirstItem->NextItem->NextItem
->NextItem->NextItem->NextItem->NextItem;
return;
}
int check_menu(int *class, int *code)
/*
** FUNCTIONAL DESCRIPTION:
**
** RETURN VALUE:
** description: TRUE if you should take an action, false if not
** data_type: int
**
** ARGUMENTS:
**
** class-
** description: Intuition message class
** data_type: pointer to int
** access: write only
**
** code-
** description: Intuition message code
** data_type: pointer to int
** access: write only
**
** DESIGN:
** ROUTINE
** : clear take_action, *class and *code
** : message = GetMsg(w->UserPort)
** : IF message is valid
** : : copy message class and code
** : : Reply to the message
** : : IF class = MENUPICK and code = invalid
** : : : take_action = FALSE
** : : ELSE
** : : : take_action = TRUE
** : : ENDIF
** : ENDIF
** : return take_action
** ENDROUTINE
*/
{
auto int take_action = FALSE;
auto struct IntuiMessage *message;
take_action
= *class
= *code
= 0;
message = (struct IntuiMessage *) GetMsg(w->UserPort);
if (message != NULL)
{
*class = message->Class;
*code = message->Code;
ReplyMsg((struct Message *)message);
if ((MENUPICK == *class) && (MENUNULL == *code))
{
take_action = FALSE;
}
else
{
take_action = TRUE;
}
}
return take_action;
}
void close_menu(void)
/*
** FUNCTIONAL DESCRIPTION:
** Closes the menu
**
*/
{
ClearMenuStrip(w);
FreeMenus(menuStrip);
return;
}
void clear_record(void)
{
record_item->Flags &= ~CHECKED;
return;
}